package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.Expense;
import cn.wolfcode.trip.base.service.IExpenseService;
import cn.wolfcode.trip.base.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//查询交易记录
@RestController
@RequestMapping("expenses")
public class ExpenseController {

    @Autowired
    private IExpenseService expenseService;

    @GetMapping("/list/{id}")
    public JSONResult listAll(@PathVariable Long id) {
        JSONResult json = new JSONResult();
        List<Expense> expenses = expenseService.selectAll(id);
        json.setResult(expenses);
        return json;
    }
}
